package com.ktgj.customer.service.impl;

import java.util.Date;
import java.util.List;
import com.ktgj.common.core.utils.DateUtils;
import com.ktgj.customer.domain.vo.MallBannerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktgj.customer.mapper.MallBannerMapper;
import com.ktgj.customer.domain.MallBanner;
import com.ktgj.customer.service.IMallBannerService;

/**
 * 商城轮播Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-13
 */
@Service
public class MallBannerServiceImpl implements IMallBannerService 
{
    @Autowired
    private MallBannerMapper mallBannerMapper;

    /**
     * 查询商城轮播
     * 
     * @param bannerId 商城轮播ID
     * @return 商城轮播
     */
    @Override
    public MallBanner selectMallBannerById(Long bannerId)
    {
        return mallBannerMapper.selectMallBannerById(bannerId);
    }

    /**
     * 查询商城轮播列表
     * 
     * @param mallBanner 商城轮播
     * @return 商城轮播
     */
    @Override
    public List<MallBanner> selectMallBannerList(MallBanner mallBanner)
    {
        return mallBannerMapper.selectMallBannerList(mallBanner);
    }

    /**
     * 新增商城轮播
     * 
     * @param mallBanner 商城轮播
     * @return 结果
     */
    @Override
    public int insertMallBanner(MallBanner mallBanner)
    {
        mallBanner.setCreateTime(DateUtils.getNowDate());
        mallBanner.setUpdateTime(DateUtils.getNowDate());
        return mallBannerMapper.insertMallBanner(mallBanner);
    }

    /**
     * 修改商城轮播
     * 
     * @param mallBanner 商城轮播
     * @return 结果
     */
    @Override
    public int updateMallBanner(MallBanner mallBanner)
    {
        mallBanner.setUpdateTime(DateUtils.getNowDate());
        return mallBannerMapper.updateMallBanner(mallBanner);
    }

    /**
     * 批量删除商城轮播
     * 
     * @param bannerIds 需要删除的商城轮播ID
     * @return 结果
     */
    @Override
    public int deleteMallBannerByIds(Long[] bannerIds)
    {
        return mallBannerMapper.deleteMallBannerByIds(bannerIds);
    }

    /**
     * 删除商城轮播信息
     * 
     * @param bannerId 商城轮播ID
     * @return 结果
     */
    @Override
    public int deleteMallBannerById(Long bannerId)
    {
        return mallBannerMapper.deleteMallBannerById(bannerId);
    }

    //轮播管理列表
    @Override
    public List<MallBannerVO> mallBannerList(Long typeId, Long apptypeId, Long jumbtypeId, String title) {
        return mallBannerMapper.mallBannerList(typeId, apptypeId, jumbtypeId, title);
    }

    //Banner图详情
    @Override
    public MallBannerVO mallBannerById(Long bannerId) {
        return mallBannerMapper.mallBannerById(bannerId);
    }

    //修改Banner图详情
    @Override
    public int updateMallBanner(MallBannerVO banner) {
        MallBanner mallBanner = new MallBanner();
        BeanUtils.copyProperties(banner, mallBanner);
        return updateMallBanner(mallBanner);
    }

    //删除Banner图
    @Override
    public int deleteMallBanner(Long bannerId) {
        MallBanner banner = new MallBanner();
        banner.setBannerId(bannerId);
        banner.setDeleteTime(new Date());
        return updateMallBanner(banner);
    }

    //商城轮播
    @Override
    public List<MallBannerVO> mallBanner() {
        return mallBannerMapper.mallBanner();
    }
}
